Skip to content

Log invalid use of _cf_ table prefix#6448

Merged
maxmcd merged 1 commit intomainfrom
mmcdonnell/cf-table-prefix-logs
Mar 31, 2026
Merged

Log invalid use of _cf_ table prefix#6448
maxmcd merged 1 commit intomainfrom
mmcdonnell/cf-table-prefix-logs

Conversation

@maxmcd
Copy link
Copy Markdown
Contributor

@maxmcd maxmcd commented Mar 27, 2026

Add warning logs to detect SQL identifiers using mixed-case cf prefix variants (e.g. CF, Cf) and FTS5 virtual tables using any-case cf prefix.

@maxmcd maxmcd requested review from a team as code owners March 27, 2026 21:48
Copy link
Copy Markdown
Contributor

@ask-bonk ask-bonk bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm Bonk, and I've done a quick review of your PR.

This PR adds warning logs to detect mixed-case _cf_ prefix usage in SQL identifiers and FTS5 virtual tables.

Issues

  1. [High] <strings.h> included unconditionally — breaks Windows/MSVC build.
    strncasecmp is a POSIX function declared in <strings.h>, which doesn't exist on MSVC. Other files in the codebase handle this: form-data.c++ guards the include with #if !_MSC_VER, and sqlite.c++ uses #define strncasecmp _strnicmp. The new code in sql.c++ does neither.

  2. [Low] Log messages don't include the offending identifier.
    Since LOG_WARNING_PERIODICALLY is rate-limited to once per hour per call site, including the actual name would be much more useful for debugging when these fire in production. Both call sites have the name readily available.

@ask-bonk
Copy link
Copy Markdown
Contributor

ask-bonk bot commented Mar 27, 2026

Review posted successfully on PR #6448. Here's a summary of the findings:

  1. [High] <strings.h> portability issue — The POSIX header is included unconditionally in sql.c++, which will break Windows/MSVC builds. Suggested a platform-guarded fix matching the pattern used in sqlite.c++.

  2. [Low] Log messages missing identifier names — Both LOG_WARNING_PERIODICALLY call sites omit the offending SQL identifier/table name. Since these are rate-limited to once per hour, including the name would significantly help debugging.

All three issues have concrete suggestion comments on the PR.

github run

@maxmcd maxmcd force-pushed the mmcdonnell/cf-table-prefix-logs branch 2 times, most recently from 5fb5497 to f0f2b43 Compare March 29, 2026 17:41
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Mar 29, 2026

Codecov Report

❌ Patch coverage is 11.11111% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 70.91%. Comparing base (2db3d89) to head (c084caf).

Files with missing lines Patch % Lines
src/workerd/api/sql.c++ 20.00% 2 Missing and 2 partials ⚠️
src/workerd/util/sqlite.c++ 0.00% 4 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6448   +/-   ##
=======================================
  Coverage   70.91%   70.91%           
=======================================
  Files         428      428           
  Lines      119919   119927    +8     
  Branches    18996    19002    +6     
=======================================
+ Hits        85035    85041    +6     
- Misses      23597    23600    +3     
+ Partials    11287    11286    -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@maxmcd maxmcd force-pushed the mmcdonnell/cf-table-prefix-logs branch from f0f2b43 to 3bd6994 Compare March 30, 2026 20:08
@maxmcd maxmcd force-pushed the mmcdonnell/cf-table-prefix-logs branch from 3bd6994 to c084caf Compare March 31, 2026 01:06
@maxmcd maxmcd merged commit 370b07a into main Mar 31, 2026
33 of 34 checks passed
@maxmcd maxmcd deleted the mmcdonnell/cf-table-prefix-logs branch March 31, 2026 01:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants